#include "QRegister.h"

QRegister::QRegister(QWidget *parent) : QWidget(parent)
{

    this->setWindowIcon(QIcon(":/ALL/Image/ALL/Cat.png"));
    this->setWindowFlags(Qt::FramelessWindowHint);
    QSize SizeOfWindow = QSize(450,869);
    this->setFixedSize(SizeOfWindow);
    LabelOfRegisterbackground = new QLabel(this);
    LabelOfRegisterbackground->setGeometry(0,0,450,869);
    LabelOfRegisterbackground->setStyleSheet("QLabel {border-image:url(:/Register/Image/Register/bg3.png)}");
    this->setStyleSheet("QRegister {background-color:rgb(252,252,251)}");


    LabelOfUsrname = new QLabel(this);
    LineeditOfUsrname = new QLineEdit(this);
    LabelOfPsw = new QLabel(this);
    LineeditOfPsw = new QLineEdit(this);
    ComboboxOfArea = new QComboBox(this);
    LineeditOfPhoneNumber = new QLineEdit(this);
    LineeditOfVerificationCode = new QLineEdit(this);
    BtnOfGetVerificationCode = new QPushButton(this);
    CheckboxOfAgree = new QCheckBox(this);
    LabelOfAgreement = new QLabel(this);
    BtnOfRegister = new QPushButton(this);
    BtnOfGoToLogin = new QPushButton(this);
    BtnOfShowAgreement = new QPushButton(this);
    LabelOfMakeSurePSW = new QLabel(this);
    LineeditOfMakeSurePSW = new QLineEdit(this);

    CloseBtn = new QToolButton(this);
    MinimizeBtn = new QToolButton(this);

    CloseBtn->setGeometry(405,0,45,45);
    MinimizeBtn->setGeometry(365,0,45,45);

    //控件布局
    int first_x = 25;
    int Ry = 315;
    int first_width = 80;
    int Rheight = 45;
    int second_x = first_x + first_width + 10;
    int second_width = 400 - first_width - 10;
    int Vinterval = Rheight+25;
    LabelOfUsrname->setGeometry(first_x,Ry,first_width,Rheight);
    LineeditOfUsrname->setGeometry(second_x,Ry,second_width,Rheight);

    LabelOfPsw->setGeometry(first_x,Ry+Vinterval,first_width,Rheight);
    LineeditOfPsw->setGeometry(second_x,Ry+Vinterval,second_width,Rheight);

    LabelOfMakeSurePSW->setGeometry(first_x,Ry+Vinterval*2,first_width,Rheight);
    LineeditOfMakeSurePSW->setGeometry(second_x,Ry+Vinterval*2,second_width,Rheight);

    ComboboxOfArea->setGeometry(first_x,Ry+Vinterval*3,first_width+80,Rheight);
    LineeditOfPhoneNumber->setGeometry(second_x+80,Ry+Vinterval*3,second_width-80,Rheight);

    LineeditOfVerificationCode->setGeometry(first_x,Ry+Vinterval*4,400,Rheight);
    BtnOfGetVerificationCode->setGeometry(325-first_width,Ry+Vinterval*4,first_width+100,Rheight);

    BtnOfRegister->setGeometry(first_x,Ry+Vinterval*5,400,Rheight);

    CheckboxOfAgree->setGeometry(first_x,Ry+Vinterval*6,45,Rheight);
    LabelOfAgreement->setGeometry(first_x+25,Ry+Vinterval*6,second_width,Rheight);
    BtnOfShowAgreement->setGeometry(first_x+75,Ry+Vinterval*6,second_width,Rheight);

    BtnOfGoToLogin->setGeometry(first_x,Ry+Vinterval*7,200,Rheight);

    //控件内容
    LabelOfUsrname->setText(QString::fromUtf8("昵称:"));
    LineeditOfUsrname->setPlaceholderText(QString::fromUtf8("请输入您的昵称"));
    LabelOfPsw->setText(QString::fromUtf8("密码:"));
    LabelOfMakeSurePSW->setText(QString::fromUtf8("确认密码:"));
    LineeditOfPsw->setPlaceholderText(QString::fromUtf8("请输入您的密码"));
    LineeditOfMakeSurePSW->setPlaceholderText(QString::fromUtf8("请再次输入您的密码"));
    LineeditOfPhoneNumber->setPlaceholderText(QString::fromUtf8("请输入您的常用手机号码"));
    LineeditOfVerificationCode->setPlaceholderText(QString::fromUtf8("请输入验证码"));
    BtnOfGetVerificationCode->setText(QString::fromUtf8("获取验证码"));
    LabelOfAgreement->setText(QString::fromUtf8("我同意"));
    BtnOfRegister->setText(QString::fromUtf8("注册黑猫直播"));
    BtnOfGoToLogin->setText(QString::fromUtf8("已有账号,这就去登录"));
    BtnOfShowAgreement->setText(QString::fromUtf8("《黑猫直播用户管理条例》"));
    QStringList StringlistOfNumberArea;
    StringlistOfNumberArea<<"中国大陆"<<"中国香港特区"<<"中国澳门特区"<<"中国台湾省";
    ComboboxOfArea->addItems(StringlistOfNumberArea);

    BtnOfShowAgreement->setObjectName("RegisterBtnOfText");
    BtnOfGoToLogin->setObjectName("RegisterBtnOfText");
    BtnOfRegister->setObjectName("RegisterBtn");
    BtnOfGetVerificationCode->setObjectName("RegisterBtn");
    CloseBtn->setObjectName("CloseBtn");
    MinimizeBtn->setObjectName("MinimizeBtn");
    LineeditOfUsrname->setObjectName("RegisterLineedit");
    LineeditOfPsw->setObjectName("RegisterLineedit");
    LineeditOfMakeSurePSW->setObjectName("RegisterLineedit");
    LineeditOfPhoneNumber->setObjectName("RegisterLineedit");
    LineeditOfVerificationCode->setObjectName("RegisterLineedit");
    LabelOfPsw->setObjectName("RegisterLabel");
    LabelOfMakeSurePSW->setObjectName("RegisterLabel");
    LabelOfUsrname->setObjectName("RegisterLabel");
    LabelOfAgreement->setObjectName("RegisterLabel");
    LabelOfRegisterbackground->setObjectName("RegisterLabel");
    LineeditOfPsw->setEchoMode(QLineEdit::Password);

    QReadQSS::setStyle(":/QSS/QSS/Rester.qss");
    connect(CloseBtn,SIGNAL(clicked()),this,SLOT(close()));
    connect(MinimizeBtn,&QToolButton::clicked,this,&QRegister::showMinimized);
    connect(BtnOfShowAgreement,&QPushButton::clicked,this,QRegister::SLOTFunShowAgreement);
    connect(BtnOfGoToLogin,SIGNAL(clicked()),this,SLOT(SLOTFunOfGoToLogin()));
}

void QRegister::SLOTFunShowAgreement()
{
    QAgreement agreement;
    agreement.exec();
}

void QRegister::SLOTFunOfGoToLogin()
{
    emit SIGNALOfGoToLogin();
    this->close();
}
